﻿
#include <locale.h>

#include "ace/OS_NS_unistd.h"
#include "ace/Service_Config.h"
#include "ace/Reactor.h"
#include "ace/Log_Msg.h"
#include "ace/Signal.h"
#include "ace/Sig_Adapter.h"


static const u_short PORT=10000;

static sig_atomic_t finished = 0;
extern "C" void handler (int)
{
  finished = 1;
}

int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  setlocale(LC_ALL,"");
  ACE_STATIC_SVC_REGISTER(ClientAceptor);

 if (ACE_Service_Config::open (argc,argv,
                                ACE_DEFAULT_LOGGER_KEY,
                                0) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%p\n"),
                       ACE_TEXT ("ACE_Service_Config::open")),
                      -1);

  // Create an adapter to end the event loop.
  ACE_Sig_Adapter sa ((ACE_Sig_Handler_Ex) ACE_Reactor::end_event_loop);

  ACE_Sig_Set sig_set;
  sig_set.sig_add (SIGINT);
  sig_set.sig_add (SIGQUIT);
  
  if (ACE_Reactor::instance ()->register_handler (sig_set,
                                                  &sa) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%p\n"), ACE_TEXT ("register_handler")),
                      -1);

  
  ACE_Reactor::run_event_loop ();



  return 0;
}

